package com.pgeneral.user.management.service.impl;

import com.pgeneral.user.management.util.UUIDGenerator;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.pgeneral.user.management.entity.SopScopeData;
import com.pgeneral.user.management.dao.SopScopeDataMapper;
import com.pgeneral.user.management.service.SopScopeDataService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
*@author 龙
*@create 2020/7/2 14:18
*/
@Service
public class SopScopeDataServiceImpl implements SopScopeDataService {

    @Resource
    private SopScopeDataMapper sopscopedataMapper;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(List<SopScopeData> sopScopeDatas) {
        if (sopScopeDatas != null && sopScopeDatas.size() > 0) {
            sopScopeDatas.stream().forEach(sopScopeData -> {
                sopScopeData.setScopeId(UUIDGenerator.getUUID());
            });
        }
        return sopscopedataMapper.insert(sopScopeDatas);
    }

    @Override
    public List<SopScopeData> getSopScopeDataTable(SopScopeData sopScopeData) {
        return sopscopedataMapper.getSopScopeDataTable(sopScopeData);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateSopScopeDataTable(List<SopScopeData> sopScopeDatas) {
        return sopscopedataMapper.updateSopScopeDataTable(sopScopeDatas);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateIsDeletefromSopScopeDataTable(List<String> ids) {
        return sopscopedataMapper.updateIsDeletefromSopScopeDataTable(ids);
    }
}
